import React, { useState, FC, ReactElement } from 'react';

import { aa } from './typings';

interface ITop {
    setList: (item: aa) => void
}

const Top: FC<ITop> = ({setList}): ReactElement => {
    let [inp, setInp] = useState('')
    const setInpFn = (e: any): void => {
        setInp((): string => e.target.value)
    }
const setLit = (e:any):void =>{
    if (e.keyCode===13) {
        setList({
            id:Date.now(),
            title:inp,
            type:false
        })
        setInp('')
    }
    
}
    return (
        <div>
            <input
                type="text"
                value={inp}
                onChange={setInpFn}
                onKeyUp={setLit}
            />
        </div>
    );
}

export default Top;
